<template>
    <div class="chat">
        <div>
            <CommonSearch isShowRightImg :myStyles="{ width: '350px' }" :hit="$t('text.Customer.l93')"></CommonSearch>
            <div class="leftList">
                <div class="flex" v-for="(item, index) in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" v-bind:key="item"
                    @click="selectIndex = index" :style="selectIndex == index ? { background: '#f2f2f2' } : ''">
                    <div><img class="img1" src="../../assets/images/userHead.png"></div>
                    <div class="l1">
                        <div class="l2">
                            <div class="l4">王经理(人工岛总店)</div>
                            <div class="l5">5/6 22:22</div>
                        </div>
                        <div class="l3">周五有时间吗?可以约你看一下帝国大厦南门口附近的总统套房吗？</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="l6">
            <div class="title"><span style="padding-right: 20px;">经纪人-王小二</span><span>5/6 22:22</span></div>
            <div class="l7">
                <div v-for="item in chatList" v-bind:key="item">
                    <div class="l8" v-if="item.type == 'other'">{{ item.message }}</div>
                    <el-divider v-if="item.type == 'time'">
                        {{ item.message }}
                    </el-divider>
                    <div class="l9" v-if="item.type == 'me'">{{ item.message }}</div>
                </div>
            </div>
        </div>

    </div>
</template>
    
<script>
import CommonSearch from '@/components/input/CommonSearch.vue';


export default {
    name: 'CustomChat',
    components: {
    CommonSearch
},
    props: {
    },
    data() {
        return {
            selectIndex: -1,
            chatList: [
                { type: 'other', message: '您好,我是迪拜房产旗下的经纪人-王经理.很高兴为您服务!' },
                { type: 'me', message: '你好,我能想买个房' },
                { type: 'other', message: '请问你有没有意向的房源呢' },
                { type: 'other', message: '或者说一下你的购房需求,我这边可以帮你推荐一些合适的房源' },
                { type: 'time', message: '12:34' },
                { type: 'me', message: '沿海的海湾别墅,比如,碧桂园海湾IN+小镇的别墅,最好是联排别墅,面积在300平米左右,5室以上,客厅要超级大的,预算中1000万内,最好能自带车位,有两个车位,因为我有两台车要用.阳台能看到大海吧,暂时能想到的就这么多' },
                { type: 'other', message: '好的,我稍后将满足你需求的房源分享给你' },
            ],
            chatList1: [
                { type: 'other', message: '您好,我是迪拜房产旗下的经纪人-王经理.很高兴为您服务!' },
                { type: 'me', message: '你好,我能想买个房' },
                { type: 'other', message: '请问你有没有意向的房源呢' },
                { type: 'other', message: '或者说一下你的购房需求,我这边可以帮你推荐一些合适的房源' },
                { type: 'time', message: '12:34' },
                { type: 'me', message: '沿海的海湾别墅,比如,碧桂园海湾IN+小镇的别墅,最好是联排别墅,面积在300平米左右,5室以上,客厅要超级大的,预算中1000万内,最好能自带车位,有两个车位,因为我有两台车要用.阳台能看到大海吧,暂时能想到的就这么多' },
                { type: 'other', message: '好的,我稍后将满足你需求的房源分享给你' },
            ],
            chatList2: [
                { type: 'other', message: '您好!' },
                { type: 'me', message: '你好,我是秦始皇转世，现在急需要一套房用来东山再起，到时候封你为上将军，所以你能送我套房吗' },
                { type: 'other', message: '不能' },
                { type: 'time', message: '12:34' },
                { type: 'me', message: '为什么？' },
            ],
        }
    },
    mounted() {
    },
    methods: {
    },
    watch: {
        selectIndex:{
            handler(newValue) {
                if(newValue%2==0){
                    this.chatList=this.chatList1
                }else{
                    this.chatList=this.chatList2
                }
            }
        }
    },
    computed: {
    }

}
</script>
    
<style scoped>
.chat {
    padding-left: 35px;
    padding-right: 35px;
    padding-top: 20px;
    display: flex;
}

.flex {
    display: flex;
    height: 65px;
    align-items: center;
    padding: 0 15px;
}

.leftList {
    width: 318px;
    padding: 15px 0;
    height: 600px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 10px;
    overflow-y: scroll;
}

.leftList::-webkit-scrollbar {
    /*滚动条整体样式*/
    width: 2px;
    /*高宽分别对应横竖滚动条的尺寸*/
    height: 0px;
    background-color: white;
    /*滚动槽颜色*/
}

.leftList::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    border-radius: 5px;
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    background-color: #79bbff;
    /*滚动条颜色*/
}

.leftList::-webkit-scrollbar-track {
    /*滚动条里面轨道*/
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    border-radius: 0;
    background: rgba(0, 0, 0, 0.1);
}

.img1 {
    width: 45px;
    height: 45px;
    border-radius: 100%;
    border: 1px solid #eee;
}

.l1 {
    font-size: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 10px;
}

.l2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 7px;
}

.l3 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
}

.l5 {
    color: gray;
}

.l6 {
    padding-left: 30px;
    width: 100%;
    text-align: left;

}

.title {
    padding-bottom: 20px;
}

.l7 {
    background: #f2f2f2;
    /* width: 100%; */
    height: 602px;
    padding: 15px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
}

.l8 {
    background-color: white;
    line-height: 25px;
    padding: 5px 10px;
    border-radius: 5px;
    float: left;
    margin-top: 5px;
    margin-bottom: 10px;
    width: fit-content;
    align-self: flex-start;
    max-width: 70%;
    position: relative;
}

.l8::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    top: 8px;
    left: -10px;
    border-top: 1px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 10px solid white;
    border-radius: 5px 1px 1px 1px;
}

.l9 {
    background-color: #429df8;
    line-height: 25px;
    padding: 5px 10px;
    border-radius: 5px;
    float: right;
    margin-top: 5px;
    margin-bottom: 10px;
    max-width: 70%;
    width: fit-content;
    align-self: flex-end;
    position: relative;

}

.l9::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    top: 8px;
    right: -10px;
    border-top: 1px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 10px solid #429df8;
    border-radius: 1px 11px 11px 1px;
}


::v-deep(.el-divider__text) {
    background-color: #f2f2f2;
}
</style>